#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 创建页面实例
    detailWidget = new Detail(this);
    chartWidget = charts::getInstance(this);
    hisWidget = DataLine::instance(this);
    mvd = new MvdWindow(this);

    // 添加到 QStackedWidget
    ui->stackedWidget->addWidget(detailWidget);
    ui->stackedWidget->addWidget(chartWidget);
    ui->stackedWidget->addWidget(hisWidget);
    ui->stackedWidget->addWidget(mvd);

    // 设置初始页面
    ui->stackedWidget->setCurrentWidget(detailWidget);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_homePageButton_clicked()
{
    ui->stackedWidget->setCurrentWidget(detailWidget);
}

void MainWindow::on_chartButton_clicked()
{
    ui->stackedWidget->setCurrentWidget(chartWidget);
}

void MainWindow::on_historicalButton_clicked()
{
   ui->stackedWidget->setCurrentWidget(hisWidget);
}

void MainWindow::on_settingButton_clicked()
{
    ui->stackedWidget->setCurrentWidget(mvd);
}
